#!/usr/bin/env bash

set -eu
set -o pipefail

MY_DIR="$( dirname "${BASH_SOURCE[0]}" )"
. "${MY_DIR}/scripts/config.sh"

export JAVA_OPTS="-ea -Dfile.encoding=UTF-8 -XX:ParallelGCThreads=2 -Xmx8g -XX:+CMSClassUnloadingEnabled"

## so we don't have to type out "edu.cmu.lti.nlp.amr." every time
klass="edu.cmu.lti.nlp.amr.$1"
shift

# To run using sbt (useful for incremental compiling):
# (cd "${MY_DIR}" > /dev/null; ./sbt --error "runMain $klass $*" | grep -v '^[[]success[]] Total time:.*completed.*')   # Hack to get rid of sbt logging message

# To run directly (assumes you've built an assembly with `./compile` or `./sbt assembly`):
java ${JAVA_OPTS} -cp "${CLASSPATH}" "$klass" "$@"
